package com.fire.control.system.module.warning.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fire.control.system.config.redis.RedisService;
import com.fire.control.system.entity.WarningProtocol;
import com.fire.control.system.module.warning.dao.WarningProtocolMapper;
import com.fire.control.system.module.warning.service.WarningProtocolService;
import com.fire.control.system.statics.Key;

@Service
public class WarningProtocolServiceImpl implements WarningProtocolService{

	@Autowired WarningProtocolMapper warningProtocolMapper;
	@Autowired RedisService redisService;
	
	public WarningProtocol getWarningProtocolByFport(String fport){
		WarningProtocol warningType = redisService.getObject(Key.redis_key_lora_fPort_+fport, WarningProtocol.class);
		if(warningType==null){
			warningType = warningProtocolMapper.getWarningProtocolByFport(fport);
			redisService.setObject(Key.redis_key_lora_fPort_+fport, warningType,Key.redis_key_lora_fPort_.getExpire());
		}
		return warningType;
	}
	
}
